package com.xq.service.tesk;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xq.base.ResponseResult;
import com.xq.service.IdentityService;

import java.util.concurrent.Callable;

public class IdentityAuthTask implements Callable<Boolean> {

    private String name;
    private String cardId;
    private String baseFrontImage;
    private IdentityService identityService;

    public IdentityAuthTask(String name,String cardId,String baseFrontImage,IdentityService identityService){
        this.name=name;
        this.cardId=cardId;
        this.baseFrontImage=baseFrontImage;
        this.identityService=identityService;
    }

    @Override
    public Boolean call() throws Exception {
        boolean flag = false;
        String str = identityService.identityAuth(name,cardId,baseFrontImage);
        System.out.println("身份认证结果::"+str);
        JSONObject json = JSON.parseObject(str);
        Integer code = json.getInteger("code");
        //0代表成功
        if(code==0){
            JSONObject data = json.getJSONObject("data");
            Integer score = data.getInteger("score");
            if(score>75){
                flag=true;
            }
        }

        return flag;
    }
}
